loadCartList()
async function loadCartList(){
    let uid= localStorage.getItem("uid");
    console.log(uid);
    let {data}=await axios.get(CartListAPI,{
        params: {id:uid},
    })
    console.log(data);
    let resArr =data.data.map((res)=>`
                    <div class="cart9">
                    <div class="cart10">
                        <input type="checkbox" class="cart12">
                        <img src="${res.pimg}" alt="">
                    </div>
                    <div class="cart11">
                        <div class="cart13">
                            <p>${res.pname}</p>
                            <!-- <a href="">赠品|OPPO 半入耳式耳机 Type-C接口</a> -->
                        </div>

                        <div class="cart14">${res.pprice}</div>
                        <div class="cart15">
                            <button class="cart16" >-</button>
                            <input type="text" class="cart17" value="${res.pnum}">
                            <button class="cart18" >+</button>
                        </div>

                        <div class="cart19">
                            <span>${res.pprice}</span>
                        </div>

                        <div class="cart20" onclick="delFn(${res.pid},this)">
                            <span >删除商品</span>
                        </div>
                    </div>
                </div>
    `)


    let listCart = document.querySelector(".cart9");
    listCart.innerHTML=resArr.join("");



    // function addBtn(pid,btn){
        
    // }
    let addBtn = document.querySelectorAll(".cart18");
     console.log(addBtn);

     addBtn.forEach(function(addbtn){
        console.log(addbtn);
        addbtn.onclick = function(){
            console.log(333);
            let ipt = addbtn.previousElementSibling;
            console.log(ipt);
            let pnum = ipt.value;
            console.log(pnum);
            pnum++;
            console.log(pnum);
            ipt.value=pnum;
        }
     })
    

    // function subBtn(pid,btn){
        
    // }
    let subBtn = document.querySelectorAll(".cart16");
    console.log(subBtn);

    subBtn.forEach(function(subbtn){
        subbtn.onclick = function(){
            console.log(555);
            let ipt = subbtn.nextElementSibling;
            console.log(ipt);
            let pnum = ipt.value
            console.log(pnum);
            if(pnum == 1){
                pnum=1;
            }else{
                pnum--;
            }
            ipt.value = pnum;
        }
    })


    function delFn(){
        console.log(666);
        // let pid = localStorage.getItem("pid");
        // console.log(pid);
    }

// let delBtn = document.querySelectorAll(".cart20")
//     delBtn.forEach(function(delbtn){
//         console.log(delbtn);
//         delbtn.onclick= async function(pid,btn){
//             console.log(pid);
//             // console.log(6666);
//             let uid=localStorage.getItem("uid");
//             console.log(uid);
//             // let token = localStorage.getItem("token")
//             // console.log(token);
//             let {data}=await axios.get(CartDeleteAPI,{params: {uid,pid}})
//             console.log(data);
//         }
//     })

    
    
}